<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="Workflow.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>Workflow.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'Workflow.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/Workflow.html">draw2d.Workflow</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* This notice must be untouched at all times.

FreeGroup Draw2D 0.9.26
The latest version is available at
http://www.freegroup.de

Copyright (c) 2006 Andreas Herz. All rights reserved.
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/</span>

<span class="comment">/**
 * 
 * <span class="attrib">@version</span> 0.9.26
 * <span class="attrib">@author</span> Andreas Herz
 * <span class="attrib">@constructor</span>
 */</span>
draw2d.Workflow=<span class="reserved">function</span>(<span class="comment">/*:String*/</span>id)
{
   try
   {
      <span class="reserved">if</span>(!id)
        <span class="reserved">return</span>;
        
      <span class="reserved">this</span>.isIPad = navigator.userAgent.match(/iPad/i)  != null;
      

      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.menu = null;
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.gridWidthX = 10; <span class="comment">/*:int*/</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.gridWidthY = 10; <span class="comment">/*:int*/</span>
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.snapToGridHelper = null;
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.verticalSnapToHelperLine = null; <span class="comment">/*:draw2d.Line*/</span>

      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.horizontalSnapToHelperLine = null; <span class="comment">/*:draw2d.Line*/</span>
    
      <span class="reserved">this</span>.snapToGeometryHelper = null;

      <span class="comment">// Ein Workflow enthält Elemente</span>
      <span class="comment">//</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.figures     = new draw2d.ArrayList();
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.lines       = new draw2d.ArrayList();
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.commonPorts = new draw2d.ArrayList();
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.dropTargets = new draw2d.ArrayList();
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.compartments = new draw2d.ArrayList(); <span class="comment">// objects which can manage children</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.selectionListeners = new draw2d.ArrayList();
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.dialogs = new draw2d.ArrayList();
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.toolPalette = null;
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.dragging = false;
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.tooltip = null;
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.draggingLine = null;        <span class="comment">// line which will be moved via drag&amp;drop</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.draggingLineCommand = null; <span class="comment">// command for a line which will be moved via drag&amp;drop</span>
    
      <span class="comment">/** <span class="attrib">@private</span> **/</span>
      <span class="reserved">this</span>.commandStack = new draw2d.CommandStack();
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.oldScrollPosLeft = 0;
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.oldScrollPosTop  = 0;
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.currentSelection = null;            <span class="comment">// primary selection</span>
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.currentMenu = null; <span class="comment">/*:Menu*/</span>
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.connectionLine    = new draw2d.Line();
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandleStart = new draw2d.LineStartResizeHandle(<span class="reserved">this</span>); <span class="comment">// </span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandleEnd   = new draw2d.LineEndResizeHandle(<span class="reserved">this</span>);
    
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle1 = new draw2d.ResizeHandle(<span class="reserved">this</span>,1); <span class="comment">// 1 = LEFT TOP</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle2 = new draw2d.ResizeHandle(<span class="reserved">this</span>,2); <span class="comment">// 2 = CENTER_TOP</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle3 = new draw2d.ResizeHandle(<span class="reserved">this</span>,3); <span class="comment">// 3 = RIGHT_TOP</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle4 = new draw2d.ResizeHandle(<span class="reserved">this</span>,4); <span class="comment">// 4 = RIGHT_MIDDLE</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle5 = new draw2d.ResizeHandle(<span class="reserved">this</span>,5); <span class="comment">// 5 = RIGHT_BOTTOM</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle6 = new draw2d.ResizeHandle(<span class="reserved">this</span>,6); <span class="comment">// 6 = CENTER_BOTTOM</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle7 = new draw2d.ResizeHandle(<span class="reserved">this</span>,7); <span class="comment">// 7 = LEFT_BOTTOM</span>
      <span class="comment">/** <span class="attrib">@private</span> */</span>
      <span class="reserved">this</span>.resizeHandle8 = new draw2d.ResizeHandle(<span class="reserved">this</span>,8); <span class="comment">// 8 = LEFT_MIDDLE</span>
    
      <span class="reserved">this</span>.resizeHandleHalfWidth = parseInt(<span class="reserved">this</span>.resizeHandle2.getWidth()/2);
    
      draw2d.Canvas.call(<span class="reserved">this</span>,id);
    
      <span class="comment">// Panning ist immer an wenn es sich um ein iPad handelt. Ansonsten ist es per default aus</span>
      <span class="comment">//</span>
      <span class="reserved">this</span>.setPanning(<span class="reserved">this</span>.isIPad); <span class="comment">// flag for the panning feature of the workflow canvas</span>
    
      <span class="reserved">if</span>(<span class="reserved">this</span>.html!==null)
      {
        <span class="reserved">this</span>.html.style.backgroundImage=<span class="literal">"url(grid_10.png)"</span>;
        <span class="reserved">this</span>.html.className = <span class="literal">"Workflow"</span>;
    
        <span class="comment">/*
        * Determine which method to use to add the event handler.
        */</span>
        oThis = <span class="reserved">this</span>;
        <span class="comment">// Firefox seems to need to have the tabindex="0" property set to some value </span>
        <span class="comment">// so it knows this Div or Span is keyboard selectable. That allows the keyboard </span>
        <span class="comment">// event to be triggered. It is not so dumb - you might want to trap Delete or </span>
        <span class="comment">// Insert keys on a table etc. </span>
        <span class="reserved">this</span>.html.tabIndex=<span class="literal">"0"</span>;
        var contextMenu = <span class="reserved">function</span> ()
        {
          var oEvent = arguments[0] || window.event;

          oEvent.cancelBubble = true;
          oEvent.returnValue = false;
          oEvent.stopped = true;

          var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
          var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();

          var line = oThis.getBestLine(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset,null);
          <span class="reserved">if</span>(line!==null)
            line.onContextMenu(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
          <span class="reserved">else</span>
            oThis.onContextMenu(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
        };
        <span class="reserved">this</span>.html.oncontextmenu=<span class="reserved">function</span>(){<span class="reserved">return</span> false;};
        var oThis = <span class="reserved">this</span>;
        var keyDown=<span class="reserved">function</span>(event)
        {
          var ctrl = event.ctrlKey;
          oThis.onKeyDown(event.keyCode, ctrl);
        }
        var mouseDown = <span class="reserved">function</span>()
        {
          var oEvent = arguments[0] || window.event;
          <span class="reserved">if</span>(oEvent.returnValue==false)
            <span class="reserved">return</span>;
          var diffX = oEvent.clientX;
          var diffY = oEvent.clientY;
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();
          oThis.onMouseDown(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
        };
        var touchStart = <span class="reserved">function</span>( e )
        {
          var oEvent = e.touches.item(0);
          var diffX = oEvent.clientX;
          var diffY = oEvent.clientY;
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();
          oThis.onMouseDown(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
          e.preventDefault();
        };

        var mouseUp = <span class="reserved">function</span>()
        {
          var oEvent = arguments[0] || window.event;
          <span class="reserved">if</span>(oThis.currentMenu!==null)
          {
            oThis.removeFigure(oThis.currentMenu);
            oThis.currentMenu=null;
          }
          <span class="reserved">if</span>(oEvent.button==2)
            <span class="reserved">return</span>;
          var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
          var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();
          oThis.onMouseUp(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
        };
        var touchMove = <span class="reserved">function</span>( e )
        {
          var oEvent = e.touches.item(0);
          var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
          var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();
          oThis.currentMouseX = diffX+scrollLeft-xOffset;
          oThis.currentMouseY = diffY+scrollTop-yOffset;
          var obj = oThis.getBestFigure(oThis.currentMouseX, oThis.currentMouseY)
          <span class="comment">// Note: The event will be handle by "obj" if obj!==null</span>
          <span class="comment">//       Don't add additional checks for this case.</span>
          <span class="reserved">if</span>(draw2d.Drag.currentHover!==null &amp;&amp; obj===null)
          {
              var oDropEvent = new draw2d.DragDropEvent();
              oDropEvent.initDragDropEvent(<span class="literal">"mouseleave"</span>, false, oThis);
              draw2d.Drag.currentHover.dispatchEvent(oDropEvent);
          }
          <span class="reserved">else</span>
          {
            var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
            var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
            var scrollLeft = oThis.getScrollLeft();
            var scrollTop  = oThis.getScrollTop();
            var xOffset = oThis.getAbsoluteX();
            var yOffset = oThis.getAbsoluteY();
    
            oThis.onMouseMove(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
          }
          <span class="reserved">if</span>(obj===null)
            draw2d.Drag.currentHover = null;
    
          e.preventDefault();
        };

        var mouseMove = <span class="reserved">function</span>()
        {
          var oEvent = arguments[0] || window.event;
          var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
          var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();
          oThis.currentMouseX = diffX+scrollLeft-xOffset;
          oThis.currentMouseY = diffY+scrollTop-yOffset;
          var obj = oThis.getBestFigure(oThis.currentMouseX, oThis.currentMouseY)
          <span class="comment">// Note: The event will be handle by "obj" if obj!==null</span>
          <span class="comment">//       Don't add additional checks for this case.</span>
          <span class="reserved">if</span>(draw2d.Drag.currentHover!==null &amp;&amp; obj===null)
          {
              var oDropEvent = new draw2d.DragDropEvent();
              oDropEvent.initDragDropEvent(<span class="literal">"mouseleave"</span>, false, oThis);
              draw2d.Drag.currentHover.dispatchEvent(oDropEvent);
          }
          <span class="reserved">else</span>
          {
            var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
            var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
            var scrollLeft = oThis.getScrollLeft();
            var scrollTop  = oThis.getScrollTop();
            var xOffset = oThis.getAbsoluteX();
            var yOffset = oThis.getAbsoluteY();
            oThis.onMouseMove(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset);
          }
          <span class="reserved">if</span>(obj===null)
            draw2d.Drag.currentHover = null;
    
          <span class="comment">// Tooltip handling</span>
          <span class="comment">//</span>
          <span class="reserved">if</span>(oThis.tooltip!==null)
          {
            <span class="reserved">if</span>(Math.abs(oThis.currentTooltipX-oThis.currentMouseX)&gt;10 ||Math.abs(oThis.currentTooltipY-oThis.currentMouseY)&gt;10)
            {
              oThis.showTooltip(null);
            }
          }
        };
    
        var tmpDoubleClick = <span class="reserved">function</span> (oEvent)
        {
          var oEvent = arguments[0] || window.event;
          var diffX = oEvent.clientX;<span class="comment">// - oThis.html.offsetLeft;</span>
          var diffY = oEvent.clientY;<span class="comment">// - oThis.html.offsetTop;</span>
          var scrollLeft = oThis.getScrollLeft();
          var scrollTop  = oThis.getScrollTop();
          var xOffset = oThis.getAbsoluteX();
          var yOffset = oThis.getAbsoluteY();
          var line = oThis.getBestLine(diffX+scrollLeft-xOffset, diffY+scrollTop-yOffset,null);
          <span class="reserved">if</span>(line!==null)
            line.onDoubleClick();
        };
    
        <span class="reserved">if</span> (<span class="reserved">this</span>.html.addEventListener)
        {
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"contextmenu"</span>, contextMenu, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"touchstart"</span>, touchStart, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"touchmove"</span>, touchMove, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"mousemove"</span>, mouseMove, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"mouseup"</span>, mouseUp, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"mousedown"</span>, mouseDown, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"keydown"</span>, keyDown, false);
            <span class="reserved">this</span>.html.addEventListener(<span class="literal">"dblclick"</span>,tmpDoubleClick,false );
        } 
        <span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.html.attachEvent)
        {
            <span class="reserved">this</span>.html.attachEvent(<span class="literal">"oncontextmenu"</span>, contextMenu);
            <span class="reserved">this</span>.html.attachEvent(<span class="literal">"onmousemove"</span>, mouseMove);
            <span class="reserved">this</span>.html.attachEvent(<span class="literal">"onmousedown"</span>, mouseDown);
            <span class="reserved">this</span>.html.attachEvent(<span class="literal">"onmouseup"</span>, mouseUp);
            <span class="reserved">this</span>.html.attachEvent(<span class="literal">"onkeydown"</span>, keyDown);
            <span class="reserved">this</span>.html.attachEvent(<span class="literal">"ondblclick"</span>, tmpDoubleClick);
        } 
        <span class="reserved">else</span> 
        {
            throw <span class="literal">"FreeGroup Draw2D 0.9.26 not supported in this browser."</span>;
        }
      }
  }
  catch(e)
  {
     pushErrorStack(e, <span class="literal">"draw2d.Workflow=function(/*:String*/id)"</span>);
  }
};


<span class="comment">// Workflow leitet von Canvas ab</span>
<span class="comment">//</span>
draw2d.Workflow.<span class="reserved">prototype</span> = new draw2d.Canvas();
<span class="comment">/** <span class="attrib">@private</span> **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.type=<span class="literal">"draw2d.Workflow"</span>;

<span class="comment">/** <span class="attrib">@private</span> **/</span>
draw2d.Workflow.COLOR_GREEN = new  draw2d.Color(0,255,0);

draw2d.Workflow.<span class="reserved">prototype</span>.clear=<span class="reserved">function</span>()
{
   <span class="reserved">this</span>.scrollTo(0,0,true);
   <span class="reserved">this</span>.gridWidthX = 10;
   <span class="reserved">this</span>.gridWidthY = 10;
   <span class="reserved">this</span>.snapToGridHelper = null;
   <span class="reserved">this</span>.verticalSnapToHelperLine = null;
   <span class="reserved">this</span>.horizontalSnapToHelperLine = null;
   var document = <span class="reserved">this</span>.getDocument();

   var tmpLines =  document.getLines().clone();
   <span class="reserved">for</span>(var i=0;i&lt;tmpLines.getSize();i++)
   {
     (new draw2d.CommandDelete(tmpLines.get(i))).execute();
   }

   var tmpFigures =  document.getFigures().clone();
   <span class="reserved">for</span>(var i=0;i&lt;tmpFigures.getSize();i++)
   {
     (new draw2d.CommandDelete(tmpFigures.get(i))).execute();
   }

   <span class="reserved">this</span>.commonPorts.removeAllElements();
   <span class="reserved">this</span>.dropTargets.removeAllElements();
   <span class="reserved">this</span>.compartments.removeAllElements();
   <span class="reserved">this</span>.selectionListeners.removeAllElements();
   <span class="reserved">this</span>.dialogs.removeAllElements();
   <span class="reserved">this</span>.commandStack = new draw2d.CommandStack();
   <span class="reserved">this</span>.currentSelection = null;
   <span class="reserved">this</span>.currentMenu = null;
   draw2d.Drag.clearCurrent();
};

<span class="comment">/**
 * This method will be called from the framework of the document has been scrolled.
 * The canvas/workflow adjust the dialog/window element which has been a fixed position.
 *
 * <span class="attrib">@final</span>
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.onScroll=<span class="reserved">function</span>()
{
  var scrollLeft = <span class="reserved">this</span>.getScrollLeft();
  var scrollTop  = <span class="reserved">this</span>.getScrollTop();

  var diffLeft =   scrollLeft - <span class="reserved">this</span>.oldScrollPosLeft;
  var diffTop  =   scrollTop - <span class="reserved">this</span>.oldScrollPosTop;

  <span class="reserved">for</span>(var i=0;i&lt; <span class="reserved">this</span>.figures.getSize();i++)
  {
    var figure = <span class="reserved">this</span>.figures.get(i);
    <span class="reserved">if</span>(figure.hasFixedPosition &amp;&amp; figure.hasFixedPosition()==true)
      figure.setPosition(figure.getX()+diffLeft, figure.getY()+diffTop);
  }

  <span class="reserved">this</span>.oldScrollPosLeft= scrollLeft;
  <span class="reserved">this</span>.oldScrollPosTop = scrollTop;
};

draw2d.Workflow.<span class="reserved">prototype</span>.setPanning=<span class="reserved">function</span>(<span class="comment">/*:boolean*/</span>flag)
{
  <span class="reserved">this</span>.panning= flag;
  <span class="reserved">if</span>(flag)
    <span class="reserved">this</span>.html.style.cursor=<span class="literal">"move"</span>;
  <span class="reserved">else</span>
    <span class="reserved">this</span>.html.style.cursor=<span class="literal">"default"</span>;
};

<span class="comment">/**
 * You can scroll the view to a well defined position.
 *
 * <span class="attrib">@param</span> {int} x the new X scroll position
 * <span class="attrib">@param</span> {int} y the Y scroll position
**/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.scrollTo=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x, <span class="comment">/*:int*/</span>y, <span class="comment">/*:boolean*/</span> fast)
{
  <span class="reserved">if</span>(fast)
  {
   <span class="reserved">this</span>.scrollArea.scrollLeft= x;
   <span class="reserved">this</span>.scrollArea.scrollTop = y;
  }
  <span class="reserved">else</span>
  {
   var steps= 40;
   var xStep = (x-<span class="reserved">this</span>.getScrollLeft())/steps;
   var yStep = (y-<span class="reserved">this</span>.getScrollTop())/steps;

   var oldX = <span class="reserved">this</span>.getScrollLeft();
   var oldY = <span class="reserved">this</span>.getScrollTop();
   <span class="reserved">for</span>(var i=0;i&lt;steps;i++)
   {
      <span class="reserved">this</span>.scrollArea.scrollLeft= oldX + (xStep*i);
      <span class="reserved">this</span>.scrollArea.scrollTop = oldY + (yStep*i);
   }
  }
};



<span class="comment">/**
 *
 * <span class="attrib">@param</span> {draw2d.Figure} tooltip The tooltip to show
 * <span class="attrib">@param</span> {boolean} autoHide Indicate if the tooltip should be removed after a timeout period..
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showTooltip=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> tooltip, <span class="comment">/*:boolean*/</span> autoHide)
{
  <span class="reserved">if</span>(<span class="reserved">this</span>.tooltip!==null)
  {
     <span class="reserved">this</span>.removeFigure(<span class="reserved">this</span>.tooltip);
     <span class="reserved">this</span>.tooltip = null;
     <span class="reserved">if</span>(<span class="reserved">this</span>.tooltipTimer&gt;=0)
     {
       window.clearTimeout(<span class="reserved">this</span>.tooltipTimer);
       <span class="reserved">this</span>.tooltipTimer=-1;
     }
  }
  <span class="reserved">this</span>.tooltip = tooltip;
  <span class="reserved">if</span>(<span class="reserved">this</span>.tooltip!==null)
  {
     <span class="reserved">this</span>.currentTooltipX = <span class="reserved">this</span>.currentMouseX;
     <span class="reserved">this</span>.currentTooltipY = <span class="reserved">this</span>.currentMouseY;
     <span class="reserved">this</span>.addFigure(<span class="reserved">this</span>.tooltip,<span class="reserved">this</span>.currentTooltipX+10 , <span class="reserved">this</span>.currentTooltipY+10);
     var oThis = <span class="reserved">this</span>;
     var cancelTooltipByTimer = <span class="reserved">function</span>(){oThis.tooltipTimer=-1;oThis.showTooltip(null);};
     <span class="reserved">if</span>(autoHide==true)
     {
         <span class="reserved">this</span>.tooltipTimer = window.setTimeout(cancelTooltipByTimer, 5000);
     }
  }
};


<span class="comment">/**
 *
 * <span class="attrib">@param</span> {draw2d.Dialog} dialog The dialog to show.
 * <span class="attrib">@param</span> {int} x The x position.
 * <span class="attrib">@param</span> {int} y The y position.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showDialog=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Dialog*/</span>dialog ,<span class="comment">/*:int*/</span> xPos ,<span class="comment">/*:int*/</span> yPos)
{
  <span class="reserved">if</span>(xPos)
  {
    <span class="reserved">this</span>.addFigure(dialog,xPos, yPos);
  }
  <span class="reserved">else</span>
  {
    <span class="reserved">this</span>.addFigure(dialog,200, 100);
  }

  <span class="reserved">this</span>.dialogs.add(dialog);
};

<span class="comment">/**
 * <span class="attrib">@param</span> {draw2d.Menu} menu The menu to show.
 * <span class="attrib">@param</span> {int} x The x position.
 * <span class="attrib">@param</span> {int} y The y position.
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showMenu=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Menu*/</span>menu ,<span class="comment">/*:int*/</span> xPos ,<span class="comment">/*:int*/</span> yPos)
{
 <span class="reserved">if</span>(<span class="reserved">this</span>.menu!==null)
 {
   <span class="reserved">this</span>.html.removeChild(<span class="reserved">this</span>.menu.getHTMLElement());
   <span class="reserved">this</span>.menu.setWorkflow();
 }

 <span class="reserved">this</span>.menu =menu;
 <span class="reserved">if</span>(<span class="reserved">this</span>.menu!==null)
 {
   <span class="reserved">this</span>.menu.setWorkflow(<span class="reserved">this</span>);
   <span class="reserved">this</span>.menu.setPosition(xPos,yPos);

   <span class="reserved">this</span>.html.appendChild(<span class="reserved">this</span>.menu.getHTMLElement());
   <span class="reserved">this</span>.menu.paint();
  }
};

<span class="comment">/**
 * Callback method for the context menu interaction.
 * Don't override this method! Implement getContextMenu instead.
 *
 * <span class="attrib">@see</span> #getContextMenu
 * <span class="attrib">@private</span>
 * <span class="attrib">@final</span>
 * <span class="attrib">@param</span> {int} x The absolute x coordinate of the right mouse button click
 * <span class="attrib">@param</span> {int} y The absolute y coordinate of the right mouse button click
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.onContextMenu=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x, <span class="comment">/*:int*/</span>y)
{
    var menu = <span class="reserved">this</span>.getContextMenu();
    <span class="reserved">if</span>(menu!==null)
      <span class="reserved">this</span>.showMenu(menu,x,y);
};

<span class="comment">/**
 * <span class="attrib">@returns</span> null or the Menu object for this figure.
 * <span class="attrib">@type</span> draw2d.Menu
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getContextMenu=<span class="reserved">function</span>()
{
   <span class="reserved">return</span> null;
};

<span class="comment">/**
 * Set the tool window of this Canvas. At the moment a workflow instance can only handle one tool window instance.
 * <span class="attrib">@param</span> {draw2d.WindowFigure} toolWindow The tool window of the canvas
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.setToolWindow=<span class="reserved">function</span>(<span class="comment">/*:draw2d.WindowFigure*/</span> toolWindow, <span class="comment">/*:int*/</span>x, <span class="comment">/*:int*/</span>y)
{
  <span class="reserved">this</span>.toolPalette = toolWindow;

  <span class="reserved">if</span>(y)
   <span class="reserved">this</span>.addFigure(toolWindow,x,y);
  <span class="reserved">else</span>
   <span class="reserved">this</span>.addFigure(toolWindow,20,20);

  <span class="reserved">this</span>.dialogs.add(toolWindow);
};

<span class="comment">/**
 * Enable/disable the snap to grid behaviour of the canvas. All figures will snap to the grid during the
 * the drap and drop operation.
 * 
 * <span class="attrib">@param</span> {boolean} &lt;b&gt;true&lt;/b&gt; if you want snap to the grid.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.setSnapToGrid=<span class="reserved">function</span>(<span class="comment">/*:boolean*/</span> flag)
{
  <span class="reserved">if</span>(flag)
   <span class="reserved">this</span>.snapToGridHelper = new draw2d.SnapToGrid(<span class="reserved">this</span>);
  <span class="reserved">else</span>
   <span class="reserved">this</span>.snapToGridHelper = null;
};

<span class="comment">/**
 * Used to perform snapping to existing elements. Snapping is based on the existing children of a container. 
 * When snapping a rectangle, the edges of the rectangle will snap to edges of other rectangles generated from 
 * the children of the given container/canvas. Similarly, the centers and middles of rectangles will snap to each other.
 *
 * <span class="attrib">@param</span> {boolean} &lt;b&gt;true&lt;/b&gt; if you want snap to the geometry.
 */</span>
draw2d.Workflow.<span class="reserved">prototype</span>.setSnapToGeometry=<span class="reserved">function</span>(<span class="comment">/*:boolean*/</span> flag)
{
  <span class="reserved">if</span>(flag)
   <span class="reserved">this</span>.snapToGeometryHelper = new draw2d.SnapToGeometry(<span class="reserved">this</span>);
  <span class="reserved">else</span>
   <span class="reserved">this</span>.snapToGeometryHelper = null;
};


<span class="comment">/**
 * Set the grid width of the canvas.
 * 
 * <span class="attrib">@param</span> {int} dx The width of the grid.
 * <span class="attrib">@param</span> {int} dy The height of the grid.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.setGridWidth=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> dx,<span class="comment">/*:int*/</span> dy)
{
   <span class="reserved">this</span>.gridWidthX = dx;
   <span class="reserved">this</span>.gridWidthY = dy;
};

<span class="comment">/**
 * Add a figure at the hands over x/y position.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure to add.
 * <span class="attrib">@param</span> {int} x The x position.
 * <span class="attrib">@param</span> {int} y The y position.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.addFigure=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure ,<span class="comment">/*:int*/</span> xPos, <span class="comment">/*:int*/</span> yPos)
{
  try
  {
    draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,figure,xPos,yPos,true);
    figure.setWorkflow(<span class="reserved">this</span>);
    var oThisWorkflow = <span class="reserved">this</span>;
    <span class="comment">// Compartments must be stored in an additional structure</span>
    <span class="comment">//</span>
    <span class="reserved">if</span>(figure instanceof draw2d.CompartmentFigure)
    {
      <span class="reserved">this</span>.compartments.add(figure);
    }
  
    <span class="reserved">if</span>(figure instanceof draw2d.Line)
    {
      <span class="reserved">this</span>.lines.add(figure);
    }
    <span class="reserved">else</span>
    {
      <span class="reserved">this</span>.figures.add(figure);
      figure.draggable.addEventListener(<span class="literal">"drag"</span>, <span class="reserved">function</span> (oEvent)
      {
        var figure = oThisWorkflow.getFigure(oEvent.target.element.id);
        <span class="reserved">if</span>(figure===null)
          <span class="reserved">return</span>;
        <span class="reserved">if</span>(figure.isSelectable()==false)
          <span class="reserved">return</span>;
        oThisWorkflow.moveResizeHandles(figure);
      });
    }
    figure.paint();
    <span class="reserved">this</span>.setDocumentDirty();
  }
  catch(e)
  {
      pushErrorStack(e,<span class="literal">"draw2d.Workflow.prototype.addFigure=function(/*:draw2d.Figure*/ figure ,/*:int*/ xPos, /*:int*/ yPos)"</span>);
  }
};

<span class="comment">/**
 * Remove a figure from the Canvas.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure to remove
 *
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.removeFigure = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>, figure);

    <span class="reserved">this</span>.figures.remove(figure);
    <span class="reserved">this</span>.lines.remove(figure);
    <span class="reserved">this</span>.dialogs.remove(figure);

    figure.setWorkflow(null);

    <span class="reserved">if</span>(figure instanceof draw2d.CompartmentFigure)
       <span class="reserved">this</span>.compartments.remove(figure);

    <span class="reserved">if</span>(figure instanceof draw2d.Connection)
       figure.disconnect();

    <span class="reserved">if</span>(<span class="reserved">this</span>.currentSelection == figure)
      <span class="reserved">this</span>.setCurrentSelection(null);

    <span class="reserved">this</span>.setDocumentDirty();

    figure.onRemove(<span class="reserved">this</span>);
};

<span class="comment">/**
 * Move the hands over figure in front of a other figures.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure to bring on top.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.moveFront = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
  <span class="reserved">this</span>.html.removeChild(figure.getHTMLElement());
  <span class="reserved">this</span>.html.appendChild(figure.getHTMLElement());
};

<span class="comment">/**
 * Move the hands over figure back.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The figure to bring back.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.moveBack = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
  <span class="reserved">this</span>.html.removeChild(figure.getHTMLElement());
  <span class="reserved">this</span>.html.insertBefore(figure.getHTMLElement(), <span class="reserved">this</span>.html.firstChild);
};

<span class="comment">/**
 * Retruns the best comparment figure at the location [x,y].
 *
 * <span class="attrib">@param</span> {int} x The x position.
 * <span class="attrib">@param</span> {int} y The y position.
 * <span class="attrib">@param</span> {draw2d.Figure} figureToIgnore The figure which should be ignored.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getBestCompartmentFigure=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x, <span class="comment">/*:int*/</span> y, <span class="comment">/*:draw2d.Figure*/</span> figureToIgnore)
{
  var result = null;
  <span class="reserved">for</span>(var i=0;i&lt;<span class="reserved">this</span>.figures.getSize();i++)
  {
    var figure = <span class="reserved">this</span>.figures.get(i);
    <span class="reserved">if</span>((figure instanceof draw2d.CompartmentFigure) &amp;&amp; figure.isOver(x,y)==true &amp;&amp; figure!=figureToIgnore)
    {
        <span class="reserved">if</span>(result===null)
           result = figure;
        <span class="reserved">else</span> <span class="reserved">if</span>(result.getZOrder() &lt; figure.getZOrder())
           result = figure;
    }
  }
  <span class="reserved">return</span> result;
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 * <span class="attrib">@type</span> draw2d.Figure
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getBestFigure=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x, <span class="comment">/*:int*/</span> y, <span class="comment">/*:draw2d.Figure*/</span> figureToIgnore)
{
  var result = null;
  <span class="reserved">for</span>(var i=0;i &lt;<span class="reserved">this</span>.figures.getSize();i++)
  {
    var figure = <span class="reserved">this</span>.figures.get(i);
    <span class="reserved">if</span>(figure.isOver(x,y)==true &amp;&amp; figure!=figureToIgnore)
    {
        <span class="reserved">if</span>(result===null)
           result = figure;
        <span class="reserved">else</span> <span class="reserved">if</span>(result.getZOrder() &lt; figure.getZOrder())
           result = figure;
    }
  }
  <span class="reserved">return</span> result;
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 * <span class="attrib">@type</span> draw2d.Line
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getBestLine=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x, <span class="comment">/*:int*/</span> y, <span class="comment">/*:draw2d.Line*/</span> lineToIgnore)
{
  var result = null;
  var count = <span class="reserved">this</span>.lines.getSize();
  <span class="reserved">for</span>(var i=0;i&lt; count;i++)
  {
    var line = <span class="reserved">this</span>.lines.get(i);
    <span class="reserved">if</span>(line.containsPoint(x,y)==true &amp;&amp; line!=lineToIgnore)
    {
        <span class="reserved">if</span>(result===null)
           result = line;
        <span class="reserved">else</span> <span class="reserved">if</span>(result.getZOrder() &lt; line.getZOrder())
           result = line;
    }
  }
  <span class="reserved">return</span> result;
};

<span class="comment">/**
 * Returns the figure with the given id. Use &lt;b&gt;workflow.getDocument().getFigure(..)&lt;/b&gt; for the
 * public access.&lt;br&gt;
 *
 * <span class="attrib">@param</span> {String} id The id of the figure.
 * <span class="attrib">@type</span> draw2d.Figure
 * <span class="attrib">@private</span>
 * <span class="attrib">@deprecated</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getFigure=<span class="reserved">function</span>(<span class="comment">/*:String*/</span> id)
{
  <span class="reserved">for</span>(var i=0; i&lt;<span class="reserved">this</span>.figures.getSize();i++)
  {
     var figure = <span class="reserved">this</span>.figures.get(i);
     <span class="reserved">if</span>(figure.id==id)
        <span class="reserved">return</span> figure;
  }
  <span class="reserved">return</span> null;;
};


<span class="comment">/**
 * Returns the internal figures container.&lt;br&gt;
 *
 * Use &lt;b&gt;workflow.getDocument().getFigure(..)&lt;/b&gt; for the
 * public access.&lt;br&gt;
 *
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getFigures=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.figures;
};


<span class="comment">/**
 * Returns the document of the canvas.
 *
 * <span class="attrib">@type</span> draw2d.CanvasDocument
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getDocument=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> new draw2d.CanvasDocument(<span class="reserved">this</span>);
};

<span class="comment">/**
 * <span class="attrib">@see</span> draw2d.WindowFigure#onSelectionChanged
 * <span class="attrib">@param</span> {Object} w an object which implements the 'onSelectionChanged' method
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.addSelectionListener=<span class="reserved">function</span>(<span class="comment">/*:Object*/</span> w)
{
  <span class="reserved">if</span>(w!==null)
  {
    <span class="reserved">if</span>(w.onSelectionChanged)
      <span class="reserved">this</span>.selectionListeners.add(w);
    <span class="reserved">else</span>
      throw <span class="literal">"Object doesn't implement required callback method [onSelectionChanged]"</span>;
  }
};

<span class="comment">/**
 * <span class="attrib">@see</span> draw2d.WindowFigure#onSelectionChanged
 * <span class="attrib">@param</span> {Object} w The object which will be removed from the selection eventing
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.removeSelectionListener=<span class="reserved">function</span>(<span class="comment">/*:Object*/</span> w )
{
  <span class="reserved">this</span>.selectionListeners.remove(w);
};

<span class="comment">/**
 * Set the current selected figure in the workflow Canvas.&lt;br&gt;
 * Since version 0.9.18 you can select objects from type &lt;b&gt;draw2d.Figure&lt;/b&gt; too.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The new selection.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.setCurrentSelection=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure )
{
  <span class="reserved">if</span>(figure===null || <span class="reserved">this</span>.currentSelection!=figure)
  {
    <span class="reserved">this</span>.hideResizeHandles();
    <span class="reserved">this</span>.hideLineResizeHandles();
  }

  <span class="reserved">this</span>.currentSelection = figure;

  <span class="comment">// inform all selection listeners about the new selection.</span>
  <span class="comment">//</span>
  <span class="reserved">for</span>(var i=0;i &lt; <span class="reserved">this</span>.selectionListeners.getSize();i++)
  {
    var w = <span class="reserved">this</span>.selectionListeners.get(i);
    <span class="reserved">if</span>(w.onSelectionChanged)
      w.onSelectionChanged(<span class="reserved">this</span>.currentSelection, <span class="reserved">this</span>.currentSelection?<span class="reserved">this</span>.currentSelection.getModel():null);
  }
  <span class="reserved">if</span>(figure instanceof draw2d.Line)
  {
    <span class="reserved">this</span>.showLineResizeHandles(figure);
    <span class="comment">// you can move a line with Drag&amp;Drop...but not a connection.</span>
    <span class="comment">// A Connection is well bounded with the corresponding ports.</span>
    <span class="comment">//</span>
    <span class="reserved">if</span>(!(figure instanceof draw2d.Connection))
    {
       <span class="reserved">this</span>.draggingLineCommand = figure.createCommand(new draw2d.EditPolicy(draw2d.EditPolicy.MOVE));
       <span class="reserved">if</span>(<span class="reserved">this</span>.draggingLineCommand!==null)
          <span class="reserved">this</span>.draggingLine = figure;
    }
  }
};

<span class="comment">/**
 * Returns the current selected figure in the Canvas.
 *
 * <span class="attrib">@param</span> {draw2d.Figure} figure The new selection.
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getCurrentSelection=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.currentSelection;
};

<span class="comment">/**
 * Returns the line with the given id. Use &lt;b&gt;workflow.getDocument().getLine(..)&lt;/b&gt; for the
 * public access.&lt;br&gt;
 *
 * <span class="attrib">@param</span> {String} id The id of the line.
 * <span class="attrib">@type</span> draw2d.Line
 * <span class="attrib">@private</span>
 * <span class="attrib">@since</span> 0.9.15
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getLine=<span class="reserved">function</span>(<span class="comment">/*:String*/</span> id)
{
  var count = <span class="reserved">this</span>.lines.getSize();
  <span class="reserved">for</span>(var i=0; i&lt;count;i++)
  {
     var line = <span class="reserved">this</span>.lines.get(i);
     <span class="reserved">if</span>(line.getId()==id)
        <span class="reserved">return</span> line;
  }
  <span class="reserved">return</span> null;;
};

<span class="comment">/**
 * Returns all lines/connections in this workflow/canvas.&lt;br&gt;
 *
 * Use &lt;b&gt;workflow.getDocument().getLines()&lt;/b&gt; for the
 * public access.&lt;br&gt;
 *
 * <span class="attrib">@type</span> draw2d.ArrayList
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getLines=<span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.lines;
};

<span class="comment">/**
 * <span class="attrib">@param</span> {draw2d.Port} port The new port which has beend added to the workflow Canvas.
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.registerPort = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Port*/</span> port )
{
  <span class="comment">// All elements have the same drop targets.</span>
  <span class="comment">//</span>
  port.draggable.targets= <span class="reserved">this</span>.dropTargets;

  <span class="reserved">this</span>.commonPorts.add(port);
  <span class="reserved">this</span>.dropTargets.add(port.dropable);
};

<span class="comment">/**
 * <span class="attrib">@param</span> {draw2d.Port} p The port to remove from the workflow Canvas.
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.unregisterPort = <span class="reserved">function</span>(<span class="comment">/*:draw2d.Port*/</span> port )
{
  port.draggable.targets=null;

  <span class="reserved">this</span>.commonPorts.remove(port);
  <span class="reserved">this</span>.dropTargets.remove(port.dropable);
};
<span class="comment">/**
 * Returns the command stack for the Canvas. Required for undo/redo  support.
 *
 * <span class="attrib">@type</span> draw2d.CommandStack
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.getCommandStack = <span class="reserved">function</span>()
{
  <span class="reserved">return</span> <span class="reserved">this</span>.commandStack;
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showConnectionLine=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x1  ,<span class="comment">/*:int*/</span> y1 ,<span class="comment">/*:int*/</span> x2,<span class="comment">/*:int*/</span> y2 )
{
  <span class="reserved">this</span>.connectionLine.setStartPoint(x1,y1);
  <span class="reserved">this</span>.connectionLine.setEndPoint(x2,y2);
  <span class="reserved">if</span>(<span class="reserved">this</span>.connectionLine.canvas===null)
    draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.connectionLine);
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.hideConnectionLine=<span class="reserved">function</span>()
{
  <span class="reserved">if</span>(<span class="reserved">this</span>.connectionLine.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.connectionLine);
};

<span class="comment">/**
 * <span class="attrib">@param</span> {draw2d.Line} line The line for the resize handles.
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showLineResizeHandles=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Line*/</span> figure )
{
  var resizeWidthHalf = <span class="reserved">this</span>.resizeHandleStart.getWidth()/2;
  var resizeHeightHalf= <span class="reserved">this</span>.resizeHandleStart.getHeight()/2;
  var startPoint = figure.getStartPoint();
  var endPoint   = figure.getEndPoint();
  draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandleStart,startPoint.x-resizeWidthHalf,startPoint.y-resizeWidthHalf);
  draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandleEnd,endPoint.x-resizeWidthHalf,endPoint.y-resizeWidthHalf);
  <span class="reserved">this</span>.resizeHandleStart.setCanDrag(figure.isResizeable());
  <span class="reserved">this</span>.resizeHandleEnd.setCanDrag(figure.isResizeable());
  <span class="reserved">if</span>(figure.isResizeable())
  {
    <span class="reserved">this</span>.resizeHandleStart.setBackgroundColor(draw2d.Workflow.COLOR_GREEN);
    <span class="reserved">this</span>.resizeHandleEnd.setBackgroundColor(draw2d.Workflow.COLOR_GREEN);
    <span class="comment">// required for reconnect of connections</span>
   <span class="reserved">this</span>.resizeHandleStart.draggable.targets= <span class="reserved">this</span>.dropTargets;
   <span class="reserved">this</span>.resizeHandleEnd.draggable.targets= <span class="reserved">this</span>.dropTargets;

  }
  <span class="reserved">else</span>
  {
    <span class="reserved">this</span>.resizeHandleStart.setBackgroundColor(null);
    <span class="reserved">this</span>.resizeHandleEnd.setBackgroundColor(null);
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.hideLineResizeHandles=<span class="reserved">function</span>()
{
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandleStart.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandleStart);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandleEnd.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandleEnd);
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showResizeHandles=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
  <span class="reserved">this</span>.hideLineResizeHandles();
  <span class="reserved">this</span>.hideResizeHandles();

  <span class="comment">// We must reset the alpha blending of the resizeHandles if the last selected object != figure</span>
  <span class="comment">// Reason: We would fadeIn the ResizeHandles at the new selected object but the fast toggle from oldSeleciton =&gt; newSelection</span>
  <span class="comment">//         doesn't reset the alpha to 0.0. So, we do it manually.</span>
  <span class="comment">//</span>
  <span class="reserved">if</span>(<span class="reserved">this</span>.getEnableSmoothFigureHandling()==true &amp;&amp; <span class="reserved">this</span>.getCurrentSelection()!=figure)
  {
     <span class="reserved">this</span>.resizeHandle1.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle2.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle3.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle4.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle5.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle6.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle7.setAlpha(0.01);
     <span class="reserved">this</span>.resizeHandle8.setAlpha(0.01);
  }

  var resizeWidth = <span class="reserved">this</span>.resizeHandle1.getWidth();
  var resizeHeight= <span class="reserved">this</span>.resizeHandle1.getHeight();
  var objHeight   = figure.getHeight();
  var objWidth    = figure.getWidth();
  var xPos = figure.getX();
  var yPos = figure.getY();
  draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle1,xPos-resizeWidth,yPos-resizeHeight);
  draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle3,xPos+objWidth,yPos-resizeHeight);
  draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle5,xPos+objWidth,yPos+objHeight);
  draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle7,xPos-resizeWidth,yPos+objHeight);

  <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle1);
  <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle3);
  <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle5);
  <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle7);

  <span class="reserved">this</span>.resizeHandle1.setCanDrag(figure.isResizeable());
  <span class="reserved">this</span>.resizeHandle3.setCanDrag(figure.isResizeable());
  <span class="reserved">this</span>.resizeHandle5.setCanDrag(figure.isResizeable());
  <span class="reserved">this</span>.resizeHandle7.setCanDrag(figure.isResizeable());
  <span class="reserved">if</span>(figure.isResizeable())
  {
    var green = new draw2d.Color(0,255,0);
    <span class="reserved">this</span>.resizeHandle1.setBackgroundColor(green);
    <span class="reserved">this</span>.resizeHandle3.setBackgroundColor(green);
    <span class="reserved">this</span>.resizeHandle5.setBackgroundColor(green);
    <span class="reserved">this</span>.resizeHandle7.setBackgroundColor(green);
  }
  <span class="reserved">else</span>
  {
    <span class="reserved">this</span>.resizeHandle1.setBackgroundColor(null);
    <span class="reserved">this</span>.resizeHandle3.setBackgroundColor(null);
    <span class="reserved">this</span>.resizeHandle5.setBackgroundColor(null);
    <span class="reserved">this</span>.resizeHandle7.setBackgroundColor(null);
  }

  <span class="reserved">if</span>(figure.isStrechable() &amp;&amp; figure.isResizeable())
  {
    <span class="reserved">this</span>.resizeHandle2.setCanDrag(figure.isResizeable());
    <span class="reserved">this</span>.resizeHandle4.setCanDrag(figure.isResizeable());
    <span class="reserved">this</span>.resizeHandle6.setCanDrag(figure.isResizeable());
    <span class="reserved">this</span>.resizeHandle8.setCanDrag(figure.isResizeable());
    draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle2,xPos+(objWidth/2)-<span class="reserved">this</span>.resizeHandleHalfWidth,yPos-resizeHeight);
    draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle4,xPos+objWidth,yPos+(objHeight/2)-(resizeHeight/2));
    draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle6,xPos+(objWidth/2)-<span class="reserved">this</span>.resizeHandleHalfWidth,yPos+objHeight);
    draw2d.Canvas.<span class="reserved">prototype</span>.addFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle8,xPos-resizeWidth,yPos+(objHeight/2)-(resizeHeight/2));
    <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle2);
    <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle4);
    <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle6);
    <span class="reserved">this</span>.moveFront(<span class="reserved">this</span>.resizeHandle8);
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.hideResizeHandles=<span class="reserved">function</span>()
{
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle1.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle1);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle2.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle2);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle3.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle3);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle4.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle4);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle5.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle5);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle6.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle6);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle7.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle7);
  <span class="reserved">if</span>(<span class="reserved">this</span>.resizeHandle8.canvas!==null)
    draw2d.Canvas.<span class="reserved">prototype</span>.removeFigure.call(<span class="reserved">this</span>,<span class="reserved">this</span>.resizeHandle8);
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.moveResizeHandles=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span> figure)
{
  var resizeWidth = <span class="reserved">this</span>.resizeHandle1.getWidth();
  var resizeHeight= <span class="reserved">this</span>.resizeHandle1.getHeight();
  var objHeight   = figure.getHeight();
  var objWidth    = figure.getWidth();
  var xPos = figure.getX();
  var yPos = figure.getY();
  <span class="reserved">this</span>.resizeHandle1.setPosition(xPos-resizeWidth,yPos-resizeHeight);
  <span class="reserved">this</span>.resizeHandle3.setPosition(xPos+objWidth,yPos-resizeHeight);
  <span class="reserved">this</span>.resizeHandle5.setPosition(xPos+objWidth,yPos+objHeight);
  <span class="reserved">this</span>.resizeHandle7.setPosition(xPos-resizeWidth,yPos+objHeight);
  <span class="reserved">if</span>(figure.isStrechable())
  {
    <span class="reserved">this</span>.resizeHandle2.setPosition(xPos+(objWidth/2)-<span class="reserved">this</span>.resizeHandleHalfWidth,yPos-resizeHeight);
    <span class="reserved">this</span>.resizeHandle4.setPosition(xPos+objWidth,yPos+(objHeight/2)-(resizeHeight/2));
    <span class="reserved">this</span>.resizeHandle6.setPosition(xPos+(objWidth/2)-<span class="reserved">this</span>.resizeHandleHalfWidth,yPos+objHeight);
    <span class="reserved">this</span>.resizeHandle8.setPosition(xPos-resizeWidth,yPos+(objHeight/2)-(resizeHeight/2));
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.onMouseDown=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x, <span class="comment">/*:int*/</span> y)
{
  <span class="reserved">this</span>.dragging = true;
  <span class="reserved">this</span>.mouseDownPosX = x;
  <span class="reserved">this</span>.mouseDownPosY = y;

  <span class="comment">// testen ob ein tool aktive ist und diese Aktion</span>
  <span class="comment">// an das Tool weiter leiten</span>
  <span class="comment">//</span>
  <span class="reserved">if</span>(<span class="reserved">this</span>.toolPalette!==null &amp;&amp; <span class="reserved">this</span>.toolPalette.getActiveTool()!==null)
  {
    <span class="reserved">this</span>.toolPalette.getActiveTool().execute(x,y);
  }

  <span class="reserved">this</span>.showMenu(null);

  <span class="comment">// check if a line has been hit</span>
  <span class="comment">//</span>
  var line = <span class="reserved">this</span>.getBestLine(x,y);
  <span class="reserved">if</span>(line!==null &amp;&amp; line.isSelectable())
  {
    <span class="reserved">this</span>.setCurrentSelection(line);
  }
  <span class="reserved">else</span>
  {
    <span class="reserved">this</span>.setCurrentSelection(null);
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.onMouseUp=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x ,<span class="comment">/*:int*/</span> y)
{
  <span class="reserved">this</span>.dragging = false;
  <span class="reserved">if</span>(<span class="reserved">this</span>.draggingLineCommand!==null)
  {
    <span class="reserved">this</span>.getCommandStack().execute(<span class="reserved">this</span>.draggingLineCommand);
    <span class="reserved">this</span>.draggingLine = null;
    <span class="reserved">this</span>.draggingLineCommand=null;
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.onMouseMove=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> x ,<span class="comment">/*:int*/</span> y)
{
  <span class="comment">// DragDrop of a connection/Line</span>
  <span class="reserved">if</span>(<span class="reserved">this</span>.dragging===true &amp;&amp; <span class="reserved">this</span>.draggingLine!==null)
  {
   var diffX = x-<span class="reserved">this</span>.mouseDownPosX;
   var diffY = y-<span class="reserved">this</span>.mouseDownPosY;
   <span class="comment">// don't use "setStartPoint(...)". This enforce a repaint of the the connection.</span>
   <span class="comment">// We need only one repaint of the connect and this will be done with "setEndPoint(...)"</span>
   <span class="comment">// This is a simple performance "hack".</span>
   <span class="reserved">this</span>.draggingLine.startX= <span class="reserved">this</span>.draggingLine.getStartX()+diffX;
   <span class="reserved">this</span>.draggingLine.startY= <span class="reserved">this</span>.draggingLine.getStartY()+diffY;
   <span class="reserved">this</span>.draggingLine.setEndPoint(<span class="reserved">this</span>.draggingLine.getEndX()+diffX, <span class="reserved">this</span>.draggingLine.getEndY()+diffY);
   <span class="reserved">this</span>.mouseDownPosX = x;
   <span class="reserved">this</span>.mouseDownPosY = y;
   <span class="reserved">this</span>.showLineResizeHandles(<span class="reserved">this</span>.currentSelection);
  }
  <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.dragging===true &amp;&amp; <span class="reserved">this</span>.panning===true)
  {
   var diffX = x-<span class="reserved">this</span>.mouseDownPosX;
   var diffY = y-<span class="reserved">this</span>.mouseDownPosY;

   <span class="comment">// set the new viewpoint</span>
   <span class="comment">//</span>
   <span class="reserved">this</span>.scrollTo(<span class="reserved">this</span>.getScrollLeft()-diffX,  <span class="reserved">this</span>.getScrollTop()-diffY,true);

   <span class="comment">// adjust all palletes and toolbars</span>
   <span class="comment">//</span>
   <span class="reserved">this</span>.onScroll();
  }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.onKeyDown=<span class="reserved">function</span>( <span class="comment">/*:int*/</span> keyCode, <span class="comment">/*:boolean*/</span> ctrl)
{
  <span class="comment">// Figure l�scht sich selbst, da dies den KeyDown Event empfangen</span>
  <span class="comment">// kann. Bei einer Linie geht dies leider nicht, und muss hier abgehandelt werden.</span>
  <span class="comment">//</span>
  <span class="reserved">if</span>(keyCode==46 &amp;&amp; <span class="reserved">this</span>.currentSelection!==null)
     <span class="reserved">this</span>.commandStack.execute(<span class="reserved">this</span>.currentSelection.createCommand(new draw2d.EditPolicy(draw2d.EditPolicy.DELETE)));
  <span class="reserved">else</span> <span class="reserved">if</span>(keyCode==90 &amp;&amp; ctrl)
     <span class="reserved">this</span>.commandStack.undo();
  <span class="reserved">else</span> <span class="reserved">if</span>(keyCode==89 &amp;&amp; ctrl)
     <span class="reserved">this</span>.commandStack.redo();

};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.setDocumentDirty=<span class="reserved">function</span>()
{
   try
   { 
    <span class="comment">// recreate the SnapToHelper. The need the </span>
    <span class="reserved">for</span>(var i=0;i&lt;<span class="reserved">this</span>.dialogs.getSize();i++)
    {
      var d = <span class="reserved">this</span>.dialogs.get(i);
      <span class="reserved">if</span>(d!==null &amp;&amp; d.onSetDocumentDirty)
        d.onSetDocumentDirty();
    }
    <span class="reserved">if</span>(<span class="reserved">this</span>.snapToGeometryHelper!==null)
      <span class="reserved">this</span>.snapToGeometryHelper.onSetDocumentDirty();
    <span class="reserved">if</span>(<span class="reserved">this</span>.snapToGridHelper!==null)
      <span class="reserved">this</span>.snapToGridHelper.onSetDocumentDirty();
  }
  catch(e)
  {
      pushErrorStack(e,<span class="literal">"draw2d.Workflow.prototype.setDocumentDirty=function()"</span>);
  }
};


<span class="comment">/** 
 *  Adjust the x to the next grid line.
 *
 * <span class="attrib">@param</span> {int} x The x axis value to adjust.
 * <span class="attrib">@type</span> int
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.snapToHelper=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Figure*/</span>figure, <span class="comment">/*:draw2d.Point*/</span> pos)
{
   <span class="reserved">if</span>(<span class="reserved">this</span>.snapToGeometryHelper!==null)
   {
      <span class="comment">// The user drag&amp;draop a ResizeHandle</span>
      <span class="comment">//</span>
      <span class="reserved">if</span>(figure instanceof draw2d.ResizeHandle)
      {
         var snapPoint = figure.getSnapToGridAnchor();
         pos.x+= snapPoint.x;
         pos.y+= snapPoint.y;
         var result = new draw2d.Point(pos.x,pos.y);

         var snapDirections = figure.getSnapToDirection();
         var direction = <span class="reserved">this</span>.snapToGeometryHelper.snapPoint(snapDirections, pos,result);

         <span class="comment">// Show a vertical line if the snapper has modified the inputPoint</span>
         <span class="comment">//</span>
         <span class="reserved">if</span>((snapDirections &amp; draw2d.SnapToHelper.EAST_WEST) &amp;&amp; !(direction &amp; draw2d.SnapToHelper.EAST_WEST))
            <span class="reserved">this</span>.showSnapToHelperLineVertical(result.x);
         <span class="reserved">else</span>
            <span class="reserved">this</span>.hideSnapToHelperLineVertical();

         <span class="comment">// Show a horizontal line if the snapper has modified the inputPoint</span>
         <span class="comment">//</span>
         <span class="reserved">if</span>((snapDirections &amp; draw2d.SnapToHelper.NORTH_SOUTH) &amp;&amp; !(direction &amp; draw2d.SnapToHelper.NORTH_SOUTH))
            <span class="reserved">this</span>.showSnapToHelperLineHorizontal(result.y);
         <span class="reserved">else</span>
            <span class="reserved">this</span>.hideSnapToHelperLineHorizontal();

         result.x-= snapPoint.x;
         result.y-= snapPoint.y;
         <span class="reserved">return</span> result;
      }
      <span class="comment">// The user drag&amp;drop a normal figure</span>
      <span class="reserved">else</span>
      {
         var inputBounds = new draw2d.Dimension(pos.x,pos.y, figure.getWidth(), figure.getHeight());
         var result = new draw2d.Dimension(pos.x,pos.y, figure.getWidth(), figure.getHeight());

         var snapDirections = draw2d.SnapToHelper.NSEW;
         var direction = <span class="reserved">this</span>.snapToGeometryHelper.snapRectangle( inputBounds, result);

         <span class="comment">// Show a vertical line if the snapper has modified the inputPoint</span>
         <span class="comment">//</span>
         <span class="reserved">if</span>((snapDirections &amp; draw2d.SnapToHelper.WEST) &amp;&amp; !(direction &amp; draw2d.SnapToHelper.WEST))
            <span class="reserved">this</span>.showSnapToHelperLineVertical(result.x);
         <span class="reserved">else</span> <span class="reserved">if</span>((snapDirections &amp; draw2d.SnapToHelper.EAST) &amp;&amp; !(direction &amp; draw2d.SnapToHelper.EAST))
            <span class="reserved">this</span>.showSnapToHelperLineVertical(result.getX()+result.getWidth());
         <span class="reserved">else</span>
            <span class="reserved">this</span>.hideSnapToHelperLineVertical();

         <span class="comment">// Show a horizontal line if the snapper has modified the inputPoint</span>
         <span class="comment">//</span>
         <span class="reserved">if</span>((snapDirections &amp; draw2d.SnapToHelper.NORTH) &amp;&amp; !(direction &amp; draw2d.SnapToHelper.NORTH))
            <span class="reserved">this</span>.showSnapToHelperLineHorizontal(result.y);
         <span class="reserved">else</span> <span class="reserved">if</span>((snapDirections &amp; draw2d.SnapToHelper.SOUTH) &amp;&amp; !(direction &amp; draw2d.SnapToHelper.SOUTH))
            <span class="reserved">this</span>.showSnapToHelperLineHorizontal(result.getY()+result.getHeight());
         <span class="reserved">else</span>
            <span class="reserved">this</span>.hideSnapToHelperLineHorizontal();

         <span class="reserved">return</span> result.getTopLeft();
      }
   }
   <span class="reserved">else</span> <span class="reserved">if</span>(<span class="reserved">this</span>.snapToGridHelper!==null)
   {
      var snapPoint = figure.getSnapToGridAnchor();
      pos.x= pos.x+snapPoint.x;
      pos.y= pos.y+snapPoint.y;
      var result = new draw2d.Point(pos.x,pos.y);
      <span class="reserved">this</span>.snapToGridHelper.snapPoint(0,pos,result);
      result.x= result.x-snapPoint.x;
      result.y= result.y-snapPoint.y;
      <span class="reserved">return</span> result;
   }

   <span class="reserved">return</span> pos;
};


<span class="comment">/**
 *
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showSnapToHelperLineHorizontal=<span class="reserved">function</span>(<span class="comment">/*:int*/</span> horizontalLocation)
{
   <span class="reserved">if</span>(<span class="reserved">this</span>.horizontalSnapToHelperLine===null)
   {
      <span class="reserved">this</span>.horizontalSnapToHelperLine = new draw2d.Line();
      <span class="reserved">this</span>.horizontalSnapToHelperLine.setColor(new  draw2d.Color(175,175,255));
      <span class="reserved">this</span>.addFigure(<span class="reserved">this</span>.horizontalSnapToHelperLine);
   }
   <span class="reserved">this</span>.horizontalSnapToHelperLine.setStartPoint(0,horizontalLocation);
   <span class="reserved">this</span>.horizontalSnapToHelperLine.setEndPoint(<span class="reserved">this</span>.getWidth(),horizontalLocation);
};

<span class="comment">/**
 *
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.showSnapToHelperLineVertical=<span class="reserved">function</span>( <span class="comment">/*:int*/</span> verticalLocation)
{
   <span class="reserved">if</span>(<span class="reserved">this</span>.verticalSnapToHelperLine===null)
   {
      <span class="reserved">this</span>.verticalSnapToHelperLine = new draw2d.Line();
      <span class="reserved">this</span>.verticalSnapToHelperLine.setColor(new  draw2d.Color(175,175,255));
      <span class="reserved">this</span>.addFigure(<span class="reserved">this</span>.verticalSnapToHelperLine);
   }
   <span class="reserved">this</span>.verticalSnapToHelperLine.setStartPoint(verticalLocation,0);
   <span class="reserved">this</span>.verticalSnapToHelperLine.setEndPoint(verticalLocation,<span class="reserved">this</span>.getHeight());
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.hideSnapToHelperLines=<span class="reserved">function</span>()
{
  <span class="reserved">this</span>.hideSnapToHelperLineHorizontal();
  <span class="reserved">this</span>.hideSnapToHelperLineVertical();
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.hideSnapToHelperLineHorizontal=<span class="reserved">function</span>()
{
   <span class="reserved">if</span>(<span class="reserved">this</span>.horizontalSnapToHelperLine!==null)
   {
      <span class="reserved">this</span>.removeFigure(<span class="reserved">this</span>.horizontalSnapToHelperLine);
      <span class="reserved">this</span>.horizontalSnapToHelperLine = null;
   }
};

<span class="comment">/**
 * <span class="attrib">@private</span>
 **/</span>
draw2d.Workflow.<span class="reserved">prototype</span>.hideSnapToHelperLineVertical=<span class="reserved">function</span>()
{
   <span class="reserved">if</span>(<span class="reserved">this</span>.verticalSnapToHelperLine!==null)
   {
      <span class="reserved">this</span>.removeFigure(<span class="reserved">this</span>.verticalSnapToHelperLine);
      <span class="reserved">this</span>.verticalSnapToHelperLine = null;
   }
};

</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Nov 14 13:45:39 2011</div>
</body>
</html>
